package edu.hawaii.myisern.brown.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import net.sourceforge.stripes.action.Resolution;
import net.sourceforge.stripes.action.RedirectResolution;

/**
 * Provides a web interface for the MyIsern application.
 * 
 * @author Philip Johnson
 * @author Randy Cox
 */
public class MainMenuActionBean extends MyIsernActionBean {

  /**
   * Transfers user to new page: Edit Researcher.
   * 
   * @return resolution of new page.
   */
  public Resolution editResearcher() {
    loadModel();
    Map<String,String> map = model.getResearchers();
    List<String> list = new ArrayList<String>();
    list.addAll(map.values());
    getContext().getRequest().getSession().setAttribute("researchers", list);
    return new RedirectResolution("/selectResearcher.jsp");
 }

  /**
   * Transfers user to new page: Edit Organization.
   * 
   * @return resolution of new page.
   */
  public Resolution editOrganization() {
    loadModel();
    Map<String,String> map = model.getOrganizations();
    List<String> list = new ArrayList<String>();
    list.addAll(map.values());
    getContext().getRequest().getSession().setAttribute("organizations", list);
   return new RedirectResolution("/selectOrganization.jsp");
  }

  /**
   * Transfers user to new page: Edit Collaboration.
   * 
   * @return resolution of new page.
   */
  public Resolution editCollaboration() {
    loadModel();
    Map<String,String> map = model.getCollaborations();
    System.err.print("MainMenuActionBean.editCollaboration() map.size()=");
    System.err.println(map.size());
    List<String> list = new ArrayList<String>();
    list.addAll(map.values());
    System.err.print("MainMenuActionBean.editCollaboration() list.size()=");
    System.err.println(list.size());
    getContext().getRequest().getSession().setAttribute("collaborations", list);
    return new RedirectResolution("/selectCollaboration.jsp");
  }

  /**
   * Transfers user to new page: List Researcher.
   * 
   * @return resolution of new page.
   */
  public Resolution listResearcher() {
    return new RedirectResolution("/listResearcher.jsp");
  }

  /**
   * Transfers user to new page: List Organization.
   * 
   * @return resolution of new page.
   */
  public Resolution listOrganization() {
   return new RedirectResolution("/listOrganization.jsp");
  }

  /**
   * Transfers user to new page: List Collaboration.
   * 
   * @return resolution of new page.
   */
  public Resolution listCollaboration() {
    return new RedirectResolution("/listCollaboration.jsp");
  }

  /**
   * Transfers user to new page: Data Integrity Report.
   * 
   * @return resolution of new page.
   */
  public Resolution reportDataIntegrity() {
    return new RedirectResolution("/reportDataIntegrity.jsp");
  }
  
}